#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e6+5;
int m=5000000,mu[N],p[N],t; ll fi[N]; bool vs[N];
map<int,int>su; map<int,ll>sf;
#define cu(n) ((n<=m)?mu[n]:su[n])
#define cf(n) ((n<=m)?fi[n]:sf[n])
void cnt(int n){
	ll vu=1,vf=(1ll*n+1)*n/2;
	for(int i=2;i<=n;){
		int x=n/i,j=n/x;
		if(x>m && !sf.count(x)) cnt(x);
		vu-=(j-i+1)*cu(x);
		vf-=cf(x)*(j-i+1);
		if(1ll*j==(1ll<<31)-1) break;
		i=j+1;
	}
	su[n]=vu,sf[n]=vf;
}
int main()
{
    //freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
	mu[1]=fi[1]=1;
	for(int i=2;i<=m;i++){
		if(!vs[i]) mu[i]=-1,fi[i]=i-1,p[++t]=i;
		for(int j=1;j<=t && p[j]*i<=m;j++){
			int x=p[j]*i; vs[x]=1;
			if(!(i%p[j])){
				mu[x]=0; fi[x]=fi[i]*p[j];
				break;
			}
			mu[x]=-mu[i]; fi[x]=fi[i]*(p[j]-1);
		}
	}
	for(int i=2;i<=m;i++) mu[i]+=mu[i-1],fi[i]+=fi[i-1];
	int T; cin>>T;
	while(T--){
		int n; cin>>n; if(n>m && !sf.count(n)) cnt(n);
		printf("%lld %d\n",cf(n),cu(n));
	}
	return 0;
}
/*
1
1000000000
*/
